# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

pkgname=('mpc' 'mpc-devel')
pkgver=1.1.0
pkgrel=1
pkgdesc='Multiple precision complex arithmetic library'
groups=('libraries')
url='http://www.multiprecision.org'
license=('LGPL')
arch=('i686' 'x86_64')
depends=('gmp>=5.0' 'mpfr')
makedepends=('gmp-devel' 'mpfr-devel')
install=mpc.install
options=('!emptydirs')
source=(https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz{,.sig}
        mpc-1.0.1-msys2.patch)
sha1sums=('b019d9e1d27ec5fb99497159d43a3164995de2d0'
          'SKIP'
          '0fa851f841aa3d38d9688941ee46317c916da925')
validpgpkeys=('AD17A21EF8AED8F1CC02DBD9F7D5C9BF765C61E3')  # Andreas Enge


prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/mpc-1.0.1-msys2.patch

  autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr --enable-shared --disable-static
  make
  make DESTDIR="$srcdir/dest" install
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package_mpc() {
  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/bin ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/share ${pkgdir}/usr/
}

package_mpc-devel() {
  groups=('development')
  options=('staticlibs')
  pkgdesc="MPC headers and libraries"
  depends=("mpc=${pkgver}" 'gmp-devel' 'mpfr-devel')

  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/include ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/lib ${pkgdir}/usr/
}
